package com.bulong.demo.slice;

import com.bulong.demo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class MainAbilitySlice extends AbilitySlice {
    /**
     * 初始化
     **/
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);

        // 正常页面跳转
        Button buttonNormal = (Button) findComponentById(ResourceTable.Id_gotoNormal);
        buttonNormal.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent1 = new Intent();
                present(new NormalAbilitySlice(), intent1);
            }
        });

        // 粗暴的适配页面跳转
        Button bunntonRude = (Button) findComponentById(ResourceTable.Id_gotoRude);
        bunntonRude.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Intent intent1 = new Intent();
                present(new RudeAbilitySlice(), intent1);
            }
        });
    }

    /**
     * 进入 INACTIVE 状态后来到前台，然后系统调用此回调
     **/
    @Override
    public void onActive() {
        super.onActive();
    }

    /**
     * 当重新回到前台时，系统将先调用 onForeground()回调通知开发者
     **/
    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }

}
